// Loesung_von_Aufgabe_3.7_3_Trichter_und_Berg

float phi; // Potenzial
float q1 = 7E-7; // positive Ladung
float q2 = -7E-7; // negative Ladung
float epsilon = 8.8542E-12;
float fe; // Konstante fe = 1/(4*PI*epsilon)

void setup()
{
  size(800, 800, P3D);
}

void draw()
{
  background(240);
  translate(250, height/2);

  textSize(73);
  fill(255, 0, 0);
  text("x", -325, -480, -290);
  fill(0, 255, 0);
  text("y", -325, -415, -290);
  fill(0, 0, 255);
  text("z", -325, -340, -290);

  fe = 1/(4*PI*epsilon); // Berechnung von fe

  // Rotation um die y- und x-Achse
  rotateZ(0.008*mouseX);
  rotateX(-PI/2);

  // Koordinatenkreuz
  stroke(255, 0, 0);
  strokeWeight(3);
  line(-200, 0, 600, 0); // x-Achse
  stroke(0, 255, 0);
  line(0, -600, 0, 600); // y-Achse
  stroke(0, 0, 255);
  line(0, 0, 400, 0, 0, -400); // z-Achse

  // Potenzial phi und die beiden Ladungen werden gezeichnet
  for (int y = -400; y < 400; y = y + 5)
  {
    for (int x = -200; x < 600; x = x + 5)
    {
      phi = -fe*q2/sqrt(pow(x, 2) + pow(y, 2) + 0.001) - fe*q1/sqrt(pow(x - 300, 2) + pow(y, 2) + 0.001);
      stroke(0);
      strokeWeight(2);
      point(x, y, phi);

      // negative Ladung
      stroke(0, 0, 255);
      strokeWeight(50);
      point(0, 0);

      // positive Ladung
      stroke(255, 0, 0);
      strokeWeight(50);
      point(300, 0);
    }
  }
}